package com.sunny.client.v1;

import com.sunny.client.discover.IServiceDiscovery;
import com.sunny.client.discover.ZKServiceDiscovery;

import java.lang.reflect.Proxy;

/**
 * @author Sunny
 * @date 2020/2/6
 */
public class RpcProxyClient {

    private IServiceDiscovery serviceDiscovery = new ZKServiceDiscovery();

    public <T> T proxy(Class<T> interfaceClass, String version) {
        return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class<?>[]{interfaceClass}, new RpcProxyHandler(serviceDiscovery, version));
    }
}
